The DeleteFile XCMD by David Conger is public domain software and may be freely distributed
(with this documentation). No Finder replacement stack is complete without one!
When invoked, DeleteFile presents the user with a stanard Get File dialog box. The type of files displayed by the dialog depend on the parameters passed to DeleteFile. Once a file has been chosen, the user is presented with an alert to confirm the choice to delete the file. If the user clicks "OK" the file is deleted.
Bug reports, comments and requests should be directed to DCONGER via GEnie mail.
When using ResEdit or another resource mover to put DeleteFile into your own stacks, be sure to move its associated ALRT and DITL resources. They are numbered 25057 and 23580 respectively and are both named "DeleteFile."
DeleteFile can be passed up to four optional parameters of file types (file types are four letter designators of, you guessed it, the file's type. e. g. "STAK" for stacks, "APPL" for applications, "TEXT" for text files, "PNTG" for paint files, and so on.) If DeleteFile is called without parameters, the Get File dialog will present all types of files, including invisible files (such as the Desktop file). Specifying file types in the parameters will limit the files displayed to the given types. If more than four parameters are supplied only the first four will be used. File types must be enclosed in quotes and must by separated by commas if more than one parameter is used.
Errors resulting from DeleteFile are reported in the global variable "the result." Stack developers will not generally need to worry about this as the most common errors (file in use, file locked, disk locked) are handled by DeleteFile, which presents the user with an alert explaining what happened. If no file was selected or if the user decided not to delete the selected file, this information is also returned in "the result." These are the error messages which DeleteFile can return:
No file was selected.
File deletion canceled by user.
OSErr: Bad file name
OSErr: External file system
OSErr: File busy
OSErr: File locked
OSErr: File not found
OSErr: I/O error
OSErr: No such volume
OSErr: Software volume lock
OSErr: Hardware volume lock
Once again, DeleteFile handles the errors that are most likely to occur, so the developer will not generally have to worry about "the result."